<script type="text/javascript">
//Disable Youtube Ads
(function (fn) {
	if (document.readyState == "loading") {
		addEventListener("DOMContentLoaded", fn, false);
	} else {
		fn();
	}
})(function () {
	try {
		// these variables are loaded into flashVars
		var o = yt.playerConfig.args;
		for (var i in o) {
			if (o.hasOwnProperty(i) && /^(afv_)?ad/.test(i)) {
				delete o[i];
			}
		}
	} catch (e) {
	}
	var player = document.getElementById("movie_player");
	var clean_player = player.cloneNode(true);
	var flash_vars = player.getAttribute("flashvars");
	flash_vars = flash_vars.replace(/&ad[^&]+/g, "");
	clean_player.setAttribute("flashvars", flash_vars);
	player.parentNode.replaceChild(clean_player, player);

});
//Youtube customization - deactivated
var youtubeDisable = function(){
    //Disable Annotations and Autoplay per Default
     //wait 10 seconds, then disable autoplay and annotations
    console.log('In 10 seconds I will try to disable annotations and autoplay in youtube...');
	window.setTimeout(
  function(){
           console.log('Disabling autoplay and annotations in youtube player...');
           //activate the settings menu - without this we can't click anything else
           document.querySelectorAll(".ytp-settings-button").item(0).click();
           document.querySelectorAll(".ytp-settings-button").item(0).click();

           //autoplay
           if(document.querySelectorAll("div[role='menuitemcheckbox']")[0].getAttribute("aria-checked") == "true")
               document.querySelectorAll("div[role='menuitemcheckbox']")[0].click();

           //annotations
           if(document.querySelectorAll("div[role='menuitemcheckbox']")[1].getAttribute("aria-checked") == "true")
               document.querySelectorAll("div[role='menuitemcheckbox']")[1].click();
         }
  , 10000);
};
//youtubeDisable();
</script>
